home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 67 / IOPROG_67A.ISO / soft / Tools / mwsppv4.exe / COMMAND LINE.SCRIPT < prev    next >
Encoding:
Text File  |  2001-11-22  |  4.6 KB  |  155 lines

  1. !!Script
  2. // Copyright ⌐ 1997-2001 - Modelworks Software
  3. /**
  4. @Tool: Command Line~defines the command line toolbar. 
  5. @EndTool: 
  6. @Summary: ommand Line~defines the command line toolbar
  7. */
  8.  
  9. var gCommandLineComboBox = newToolBarButton("combobox");
  10. var gDirectoryComboBox = newToolBarButton("combobox");
  11. var gCommandLineMapfile = getMapFile("CommandLine.map");
  12. var gCommandLineWidth = 375;
  13. var gDirectoryWidth = 175;
  14.  
  15. function DoCommand() 
  16. {
  17.     var toolBar = newToolBar("Command Line", "docked");
  18.     setGlobal("CommandLineToolbar", toolBar);
  19.     if (toolBar)
  20.     {
  21.         var label = newToolBarButton("label");
  22.         label.width = 60;
  23.         label.text = "Command:";
  24.         toolBar.appendButton(label);
  25.         
  26.         gCommandLineComboBox.dropDownHeight = 150;
  27.         gCommandLineComboBox.width = gCommandLineWidth;
  28.         gCommandLineComboBox.scriptHandler = getScriptPath();
  29.         gCommandLineComboBox.onDropDownHandler = "OnCommandShowDropDown";
  30.         gCommandLineComboBox.onTextChangeHandler = "OnCommandTextChange";
  31.         gCommandLineComboBox.onReturnHandler = "OnCommandReturnKeyPressed";
  32.         toolBar.appendButton(gCommandLineComboBox);
  33.         
  34.         gCommandLineComboBox.text = gCommandLineMapfile.lookup("CurrentCommand", "");
  35.         setGlobal("CommandLine.CommandLineComboBox", gCommandLineComboBox);
  36.         
  37.         var insertButton = newToolBarButton( "menu" );
  38.         insertButton.scriptPath  = "\\Toolbars\\Command\\insertCommand.script";
  39.         insertButton.imagePath   = "\\Toolbars\\Images\\Command\\insert.bmp";
  40.         insertButton.description = "Insert Command";
  41.         insertButton.toolTipText = "Insert Command";
  42.         var insertButtonID = toolBar.appendButton( insertButton );
  43.         setGlobal("CommandLine.InsertButtonID", insertButtonID);
  44.         
  45.         var label = newToolBarButton("label");
  46.         label.width = 60;
  47.         label.text = "Directory:";
  48.         toolBar.appendButton(label);
  49.         
  50.         gDirectoryComboBox.dropDownHeight = 150;
  51.         gDirectoryComboBox.width = gDirectoryWidth;
  52.         gDirectoryComboBox.scriptHandler = getScriptPath();
  53.         gDirectoryComboBox.onDropDownHandler = "OnDirectoryShowDropDown";
  54.         gDirectoryComboBox.onTextChangeHandler = "OnDirectoryTextChange";
  55.         gDirectoryComboBox.onReturnHandler = "OnDirectoryReturnKeyPressed";
  56.         toolBar.appendButton(gDirectoryComboBox);
  57.         setGlobal("CommandLine.ChooseDirectoryComboBox", gDirectoryComboBox);
  58.         
  59.         gDirectoryComboBox.text = gCommandLineMapfile.lookup("CurrentDirectory", "");
  60.         setGlobal("CommandLine.DirectoryComboBox", gDirectoryComboBox);
  61.         
  62.         var insertButton = newToolBarButton( "menu" );
  63.         insertButton.scriptPath  = "\\Toolbars\\Command\\insertDirectory.script";
  64.         insertButton.imagePath   = "\\Toolbars\\Images\\Command\\insert.bmp";
  65.         insertButton.description = "Insert Directory";
  66.         insertButton.toolTipText = "Insert Directory";
  67.         var insertButtonID = toolBar.appendButton( insertButton );
  68.         setGlobal("CommandLine.InsertButtonID", insertButtonID);
  69.         
  70.         var separatorButton = newToolBarButton( "separator" );
  71.         toolBar.appendButton( separatorButton );
  72.         
  73.         var runButton = newToolBarButton( "icon" );
  74.         runButton.scriptPath  = "\\Toolbars\\Command\\run.script";
  75.         runButton.imagePath   = "\\Toolbars\\Images\\Command\\run.bmp";
  76.         runButton.description = "Run Command";
  77.         runButton.toolTipText = "Run Command";
  78.         var runCommandID = toolBar.appendButton( runButton );
  79.         setGlobal("CommandLine.RunCommandID", runCommandID);
  80.     }
  81.     toolBar.restoreState();
  82.     
  83. }
  84.  
  85.  
  86. function OnCommandShowDropDown()
  87. {
  88.     var list = gCommandLineMapfile.lookup("CommandList", null);
  89.     if (list == null)
  90.     {
  91.         list = newList();
  92.         gCommandLineMapfile.add("CommandList", list);
  93.     }
  94.     return list;
  95. }
  96.  
  97.  
  98. function OnCommandInsertTextChange()
  99. {
  100.     // Empty
  101. }
  102.  
  103. function OnCommandInsertReturnKeyPressed()
  104. {
  105.     // Empty
  106. }
  107.  
  108. function OnDirectoryShowDropDown()
  109. {
  110.     var list = gCommandLineMapfile.lookup("DirectoryList", null);
  111.     if (list == null)
  112.     {
  113.         list = newList();
  114.         gCommandLineMapfile.add("DirectoryList", list);
  115.     }
  116.     return list;
  117. }
  118.  
  119. function OnDirectoryTextChange()
  120. {
  121.     gCommandLineMapfile.add("CurrentDirectory", gDirectoryComboBox.text);
  122. }
  123.  
  124. function OnDirectoryReturnKeyPressed()
  125. {
  126.     // Empty
  127. }
  128.  
  129. // Does not work to automatically resize the toolbar
  130. function OnNotify(event, cookie)
  131. {
  132.     var toolbar = getGlobal("CommandLineToolbar");
  133.     if (toolbar && event == "window.sized")
  134.     {
  135.         var screen = Application.getWindowRect();
  136.         var width = (screen.right - screen.left - 250)/4;
  137.         
  138.         var commandLineComboBox = getGlobal("CommandLine.CommandLineComboBox");
  139.         if (commandLineComboBox)
  140.         {
  141.             commandLineComboBox.width = 3*width;
  142.         }
  143.         
  144.         var directoryComboBox = getGlobal("CommandLine.ChooseDirectoryComboBox");
  145.         if (directoryComboBox)
  146.         {
  147.             directoryComboBox.width = width;
  148.         }
  149.     }
  150. }
  151.  
  152.  
  153. !!/Script
  154.  
  155.